#ifndef ANIMATIONCOMPONENT_H
#define ANIMATIONCOMPONENT_H

#include "Component.h" // Base class: Component
#include "ComponentFactory.h"

#include "core/Object.h"
#include "gameobjects/GameObject.h"

#include "OgreAnimationState.h"

class AnimationComponent :
	public Component,
	public Ogre::FrameListener
{

public:
	AnimationComponent() : Component() { init(); }
	AnimationComponent(ComponentContainer* c, const std::string& name) :
		Component(c, name)
	{
		init();
	}
	virtual ~AnimationComponent();

	void init();

//	inline void setStateEnabled(const Ogre::String& name, bool enabled)
	inline void setStateEnabled(const Ogre::String& name)
	{
		::Object state = anim->getProperty< ::Object>(name);
		bool enabled = state.getProperty<bool>("enabled");
		mEntity->getAnimationState(name)->setEnabled(enabled);
	}


	virtual bool frameStarted(const FrameEvent& evt);

	virtual std::string toString(void) const { return "AnimationComponent"; }

protected:
	::GameObject* mGo;
	Ogre::Entity* mEntity;

	::Object* anim;
//	Object skel;

	Ogre::AnimationStateSet* mStates;
};

#endif // ANIMATIONCOMPONENT_H
